from ucolor import utils


def test_clamp() -> None:
    assert utils._clamp(-1, 0, 1) == 0
    assert utils._clamp(0.64, 0, 1) == 0.64
    assert utils._clamp(15, -2323, 14.999999999) == 14.999999999
    assert utils._clamp(0.04, -2323, 1) == 0.04
    assert utils._clamp(-2322.9, -2323, 0) == -2322.9


def test_lerp() -> None:
    assert utils._lerp(0, 1, 0.5) == 0.5
    assert utils._lerp(-1, 1, 0.5) == 0
    assert utils._lerp(-5, 5, 0.5) == 0


def test_in_range() -> None:
    assert utils._in_range(100, -5, 5) is False
    assert utils._in_range(-5.1, -5, 5) is False
    assert utils._in_range(5.1, -5, 5) is False
    assert utils._in_range(4.999999999, -5, 5) is True
    assert utils._in_range(-5, -5.00000001, 0) is True
